<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <script src="../lib/vue.js"></script>
  </head>

  <body>
    <div id="app">
      <cpn></cpn>
      <button @click="btclick">点我</button>
    </div>

    <template id="cpn">
      <div>我是子组件</div>
    </template>
    <script>
      var vm = new Vue({
        el: '#app',
        data: {},
        components: {
          cpn: {
            template: '#cpn',
            data() {
              return {
                name: '我的名字叫CPN'
              }
            },
            methods: {
              showmessage() {
                console.log('showmessage')
              }
            }
          }
        },
        methods: {
          btclick() {
            console.log(this.$children)
            this.$children[0].showmessage()
            console.log(this.$children[0].name)
          }
        }
      })
    </script>
  </body>
</html>
